// // 通过定义函数和函数的原型对象实现的类型
// // 先定义构造函数
// function Person(name) {
//   this.name = name
// }
// // 所有的实例之间共享成员借助prototype
// Person.prototype.say = function () {
//   console.log(`hi, my name is ${this.name}`)
// }
// -----------------------------------------------
// class关键字
class Person {
  constructor(name) {
    this.name = name
  }

  say() {
    console.log(`hi, my name is ${this.name}`)
  }
}

const p = new Person('tom')
p.say()
// hi, my name is tom
// -----------------------------------------------
// 类的继承 抽象出来相似的类型之间重复的地方
// extends super
class Student extends Person {
  constructor(name, number) {
    super(name)
    // this.name = name
    this.number = number
  }
  hello() {
    super.say()
    // hi, my name is jack
    console.log(`my school number is ${this.number}`)
    // my school number is 100
  }
}
const s = new Student('jack', '100')
s.hello()
